<script lang="ts" setup>
import { useLayoutMode } from "@/hooks/useLayoutMode"
import logo from "@/assets/layouts/logo.png?url"
import logoText1 from "@/assets/layouts/chatLogo.png"
import { useUserStore } from "@/store/modules/user"

interface Props {
  collapse?: boolean
}

const props = withDefaults(defineProps<Props>(), {
  collapse: true
})

const { isTop } = useLayoutMode()

const userStore = useUserStore()
const packageName = userStore.user ? userStore.user.packageName : ""
</script>

<template>
  <div class="layout-logo-container" :class="{ collapse: props.collapse, 'layout-mode-top': isTop }">
    <transition name="">
      <router-link v-if="props.collapse" key="collapse" to="/">
        <img :src="logo" class="layout-logo" />
      </router-link>
      <router-link v-else key="expand" to="/" class="expand-a flex">
        <img :src="logoText1" class="layout-logo-text" />
        <!-- <span class="ver-tag">{{ packageName }}</span> -->
      </router-link>
    </transition>
  </div>
</template>

<style lang="scss" scoped>
.layout-logo-container {
  position: relative;
  width: 100%;
  /* height: var(--v3-header-height); */
  height: 44px;
  padding: 14px 0;
  box-sizing: content-box;
  line-height: var(--v3-header-height);
  text-align: center;
  overflow: hidden;
  .layout-logo {
    display: none;
  }
  .layout-logo-text {
    width: 98px;
    height: 100%;
    /* vertical-align: middle; */
  }
  .expand-a {
    justify-content: center;
    .el-tag {
      margin-left: 4px;
    }
  }
}

.layout-mode-top {
  height: var(--v3-navigationbar-height);
  line-height: var(--v3-navigationbar-height);
}

.collapse {
  .layout-logo {
    width: 37px;
    height: 37px;
    /* vertical-align: middle; */
    display: inline-block;
  }
  .layout-logo-text {
    display: none;
  }
}
.ver-tag {
  line-height: 1;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  padding: 4px;
  background-color: var(--primary-button-color);
}
</style>
